import {directionEnum} from "../enum/directionEnum";
import touchUtil from "./touch";

export default {
  move(position: { x: number; y: number; }, direction: directionEnum, speed: number) {
    while(true) {
      let x = position.x
      let y = position.y
      switch (direction) {
        case directionEnum.top:
          y -= speed
          break
        case directionEnum.right:
          x += speed
          break
        case directionEnum.bottom:
          y += speed
          break
        case directionEnum.left:
          x -= speed
          break
      }
      if (touchUtil.isCanvasTouch(position.x, position.y)) {
        // model.randomDirection()
      }else {
        position.x = x
        position.y = y
        break
      }
    }
  }
}
